package com.imessage.action.business.sendtask;

import com.bean.*;
import com.imessage.action.BaseAction;
import com.imessage.type.BusinessTaskCmd;
import com.imessage.type.BusinessTaskState;
import com.imessage.type.BusinessTaskType;
import com.imessage.vo.TaskVo;
import io.ebean.Expr;
import io.ebean.Expression;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

public class SendTaskBaseAction extends BaseAction {

    protected final String datagrid = "datagrid-task-filter";

    protected void setExpressionList(List<Expression> expressionList, TaskVo taskVo) {
        if (StringUtils.isNotBlank(taskVo.getState())) {
            expressionList.add(Expr.eq("state", taskVo.getState()));
        }else{
            expressionList.add(Expr.ne("state", BusinessTaskState.finish.getCode()));
        }
        expressionList.add(Expr.gt("totalNum", 0));
    }


    protected void setModelAndView(ModelAndView modelAndView, BusinessTask businessTask) {
        modelAndView.addObject("businessTaskForm", businessTask);
        modelAndView.addObject("statusList", BusinessTaskState.values());
    }


}
